package cn.wolfcode.trip.base.util;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Created by 13925 on 2018/10/25.
 */

/**
 * json处理工具类
 */
public abstract class JSONUtil {
    //json映射器
    private static final ObjectMapper mapper = new ObjectMapper();

    //将对象转换成json
    public static String toJsonString(Object obj) {
        try {
            //json对象转换成字符串
            return mapper.writeValueAsString(obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
